1. Field of the Invention
The present invention relates generally to memory management. More particularly, it relates to a way to optimize memory utilization for reading a stream of variable length records. Most especially, it relates to a way of piggy-backing information concerning the memory requirements of a subsequent data transfer operation with a current operation.
2. Description of the Prior Art
Two methods are known in the art to facilitate passing of data across address spaces:
1) A two pass operation: `A` query from `A` to `B` that asks `B` how much data will be sent. `A` allocates the necessary memory, then asks `B` to pass the data.
2) Maximum allocation: `A` allocates the pre-agreed maximum memory, then asks `B` to pass the data.
The disadvantage of method 1 is that two passes are necessary to acquire the knowledge of how much memory to allocate. Two passes (ask for the size, then transfer the data) will require two address space context shifts. The disadvantage of method 2 is that memory utilization of `A` is poor. `A` always allocates the largest amount of memory for an unknown amount of data. As a result there will be unused memory that has been allocated.